package com.wangzhenyu.learn.test.java.io

import java.io.BufferedWriter
import java.io.FileWriter


@Suppress("UNUSED")
object InstanceWriter {


    //FileWriter
    fun test01() {
        val path = "D:\\picture\\test.txt"
        var fileWriter: FileWriter? = null
        try {
            fileWriter = FileWriter(path, true)

            fileWriter.write("哈哈哈哈哈我是你爹")

        } catch (e: Exception) {

        } finally {
            fileWriter?.close()
        }
    }

    //BufferedWriter
    fun test02() {
        val path = "D:\\picture\\test.txt"
        var bufferedWriter: BufferedWriter? = null
        val content: String = "\n" +
                "柚子筋\n" +
                "我们家的玉米都绝收了，一个玉米棒子上只有几颗玉米，菜也死完了，目前还没有下雨的样子，唉\n" +
                "5分钟前\n" +
                "6\n" +
                "回复\n" +
                "\n" +
                "小泉栞子\n" +
                "邓州人，确实没雨，外婆家那一点地都没怎么浇"

        try {
            bufferedWriter = BufferedWriter(FileWriter(path))
            bufferedWriter.write(content)

        } catch (e: Exception) {

        } finally {
            bufferedWriter?.close()
        }
    }


}